//
//  ArmModel.m
//  wAudioShare
//
//  Created by Anson on 14-11-8.
//  Copyright (c) 2014年 赵帅. All rights reserved.
//

#import "ArmModel.h"

@implementation ArmModel

- (id)initWithJSON:(NSDictionary *)json {
    self = [super init];
    if (self) {
        
        _armId = [json[@"id"] integerValue];
        _label = json[@"label"];
        NSString *active = json[@"active"];
        _active = [active boolValue];
        _did = json[@"did"];
        _command = json[@"cmd"];
        _index = [json[@"index"] integerValue];
        _value = json[@"value"];
        _unit = json[@"unit"];
        _condition = json[@"cond"];
        _notify = [json[@"notify"] boolValue];
    }
    return self;
}

- (id)copyWithZone:(NSZone *)zone {
    
    ArmModel *copy = [[[self class] allocWithZone: zone] init];
    
    copy.armId = self.armId;
    copy.label = self.label;
    copy.active = self.active;
    copy.did = self.did;
    copy.command = self.command;
    copy.index = self.index;
    copy.value = self.value;
    copy.unit = self.unit;
    copy.condition = self.condition;
    copy.notify = self.notify;
    return copy;
    
}

- (NSDictionary *)jsonObj {

    NSDictionary *ret = @{@"id":[NSNumber numberWithInteger:_armId], @"label":_label, @"active":[NSNumber numberWithBool:_active], @"did":_did, @"cmd":_command, @"index":[NSNumber numberWithInteger:_index], @"value":_value, @"unit":_unit, @"cond":_condition, @"notify":[NSNumber numberWithBool:_notify]};
    return ret;
}

@end
